package com.api.shopapi.service.impl;

import com.api.shopapi.entity.ActivityPeople;
import com.api.shopapi.mapper.ActivityPeopleMapper;
import com.api.shopapi.service.ActivityPeopleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("ActivityPeopleServiceImplOne")
public class ActivityPeopleServiceImpl implements ActivityPeopleService {

    @Autowired
    private ActivityPeopleMapper activityPeopleMapper;

    @Override
    public int insert(ActivityPeople activityPeople) {
        return activityPeopleMapper.insert(activityPeople);
    }

    @Override
    public int update(ActivityPeople activityPeople) {
        return activityPeopleMapper.update(activityPeople);
    }

    @Override
    public int delete(String activityPeopleCode) {
        return activityPeopleMapper.delete(activityPeopleCode);
    }

    @Override
    public ActivityPeople getByActivityPeopleCode(String activityPeopleCode) {
        return activityPeopleMapper.getByActivityPeopleCode(activityPeopleCode);
    }

    @Override
    public ActivityPeople getByPhone(String phone, String articleCode) {
        return activityPeopleMapper.getByPhone(phone,articleCode);
    }

    @Override
    public ActivityPeople getByIdCard(String idCard, String articleCode) {
        return activityPeopleMapper.getByIdCard(idCard,articleCode);
    }


    @Override
    public PageInfo<ActivityPeople> getPage(int pageIndex, int pageSize, String articleCode,String name) {
        PageHelper.startPage(pageIndex,pageSize);
        List<ActivityPeople> activityPeopleList = activityPeopleMapper.getPage(articleCode,name);
        return new PageInfo<>(activityPeopleList);
    }

    @Override
    public ActivityPeople getByElderlyCodeAndArticleCode(String elderlyCode, String articleCode) {
        return activityPeopleMapper.getByElderlyCodeAndArticleCode(elderlyCode,articleCode);
    }
}
